﻿using BW.MesProject.Equipment.Domain.Equipment;
using BW.MesProject.Equipment.Infrastructure.Dto.Input.ProjectForm;
using BW.MesProject.Equipment.Infrastructure.Dto.Output.ProjectForm;
using BW.MesProject.Equipment.Infrastructure.Dto.Output.ProjectMaintenance;
using BW.MesProject.Equipment.Infrastructure.Equipment;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.Equipment.Host.Controllers
{
    /// <summary>
    /// 项目表单控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProjectFormController : ControllerBase
    {
        private readonly IProjectFromService projectFormService;

        public ProjectFormController(IProjectFromService projectFormService)
        {
            this.projectFormService = projectFormService;
        }

        /// <summary>
        /// 获取项目维护数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<ProjectMaintenanceModel>> GetProjectMaintenanceValue()
        {
            return projectFormService.GetProjectMaintenanceValue();
        }

        /// <summary>
        /// 新增项目表单接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddProjectForm([FromBody]AddProjectFormInput input)
        {
            return projectFormService.AddProjectForm(input);
        }

        /// <summary>
        /// 获取项目表单列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<ProjectFromOutput> GetProjectFormList([FromQuery]ProjectFormQueryInput input)
        {
            return projectFormService.GetProjectFormList(input);
        }

        /// <summary>
        /// 根据id获取项目表单数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<ProjectFromOutput> GetProjectFormValue([FromQuery]long id)
        {
            return projectFormService.GetProjectFormValue(id);
        }

        /// <summary>
        /// 更新项目表单
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateProjectForm([FromBody]UpdateProjectFormInput input)
        {
            return projectFormService.UpdateProjectForm(input);
        }

        /// <summary>
        /// 删除项目表单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteProjectForm(long id)
        {
            return projectFormService.DeleteProjectForm(id);
        }
    }
}
